<template>
  <div ww3 auto>
    <el-page-header @back="goBack" content="发票中心"> </el-page-header>

    <div fz-16 center class="top-vat">
      <span>用户名：{{user.nickname}}</span>
      <span>UID：{{user.uid}}</span>
    </div>

    <el-card class="box-card">
      <dl flex flex-c space-be>
        <dt>
          <p fz-14>
            <span>已成功开票 <i>1</i> 个</span>
            <span>总计开票金额（元）<i>2</i></span>
          </p>
        </dt>
        <!--        <el-tag type="warning">标签四</el-tag>-->
        <dd cur @click="applyVat" fz-14>申请开票</dd>
      </dl>
      <el-divider></el-divider>

      <el-table
        ref="multipleTable"
        :data="list"
        tooltip-effect="dark"
        style="width: 100%"
      >
        <el-table-column label="流水号" prop="orderNumber"></el-table-column>
        <el-table-column prop="name" label="发票金额（含税）">
          2元
        </el-table-column>
        <el-table-column prop="address" label="发票类型">
          普票（电子）
        </el-table-column>

        <el-table-column prop="name" label="发票状态"> 审核中 </el-table-column>

        <el-table-column prop="createTime" label="申请时间">
        </el-table-column>

        <el-table-column prop="date2" label="操作">
          <el-button type="text" @click="look">详情</el-button>
        </el-table-column>
      </el-table>
      <div flex ww1 style="justify-content: center; margin-top: 10px;">
        <el-pagination background layout="prev, pager, next" :page-size="pageSize" :total="total" @current-change="currentChange">
        </el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import $http from '@/api/info/info'
import $loginHttp from "@/api/login/login"
export default {
  name: "VatInvoice",

  data() {
    return {
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
      ],
      multipleSelection: [],
      disabled: true,
      pageSize: 5,
      pageNum: 1,
      total: 5,
      list: [],
      user: {}
    };
  },
  mounted() {
    this.rechargeRecordLis();
    this.getUserInfo();
    //this.user = JSON.parse(sessionStorage.getItem("user")).sysUser
  },

  methods: {
    /**
     * 获取用户信息
     */
    getUserInfo() {
      let that = this;
      let data = {
        phone: sessionStorage.getItem("userId")
      };
      $loginHttp.getUserInfo(data).then(res => {
        console.log('获取用户信息',res);
        that.user = res.data.sysUser;
      })
    },
    currentChange(value) {
      this.pageNum = value;
      this.rechargeRecordLis();
    },
    // 跳转开票
    applyVat() {
      this.$router.push('/account/vatInvoice')
    },
    goBack() {
      this.$router.go(-1);
    },
    /**
     * 获取开票数据
     */
    rechargeRecordLis() {
      let page = {
        pageSize: this.pageSize,
        pageNum: this.pageNum
      }
      let data = {
        userId: sessionStorage.getItem("userId")
      }
      $http.rechargeRecordLis(page, data).then(res => {
        console.log('111', res)
        this.total = res.total;
        this.list = res.rows;
      })
    },
    //开票
    look() {
      this.$router.push({
        name: "VatId",
        params: {
          id: 900000,
        },
      });
    },
  },
};
</script>

<style scoped>
.box-card {
  min-height: 50vh;
}
.top-vat {
  color: var(--color-black);
  margin-bottom: 2%;
}
.top-vat span,
.box-card span {
  margin-right: 20px;
}
.box-card {
}
.box-card span {
  color: var(--grey);
}
.box-card span i {
  color: var(--nav-hover-red);
}
dd {
  color: var(--green);
}
.next-btn {
  padding: 20px;
  justify-content: flex-end;
}
.next-btn dt {
  margin-right: 10px;
}
</style>
